package util;

import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;
import org.apache.hadoop.io.WritableComparable;

/**
 *
 * @author yuliu
 */
public class IntPair implements WritableComparable<IntPair> {

    int first;
    int value;

    public IntPair() {
        this.first = 0;
        this.value = 0;
    }

    public IntPair(int first, int value) {
        this.first = first;
        this.value = value;
    }

    @Override
	public int compareTo(IntPair other) {
		return this.first > other.first ? 0 : 1;
	}

    public int getIndex() {
        return first;
    }

    public int getValue() {
        return value;
    }

    @Override
    public void readFields(DataInput in) throws IOException {
    	first = in.readInt();
        value = in.readInt();
    }

    public void setIndex(int index) {
        this.first = index;
    }

    public void setValue(int value) {
        this.value = value;
    }

    @Override
    public String toString() {
        return first + ", "
                + value;
    }

	@Override
    public void write(DataOutput out) throws IOException {
        out.writeInt(first);
        out.writeInt(value);
    }
}